package com.sctu.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.sctu.EMSApp.R;
import com.sctu.bean.PlayAmuseMoreList;
import com.sctu.http.UrlConfig;
import com.sctu.httpvollry.GetVolleyHttp;

import java.util.List;

/**
 * Created by zhengsenwen on 2015/12/17.
 */
public class PlayAmuseMoreListAdapter extends BaseAdapter {

    //头部图片
    private ImageView foodlistoneheadimg;
    //item的title
    private TextView foodlistonetitletext;
    //item的价格
    private TextView foodlistonepricetext;
    //item的地址
    private TextView foodlistoneadresstext;
    //item的联系电话
    private TextView foodlistonephonetext;


    private List<PlayAmuseMoreList.Results> list;
    private Activity context;

    public PlayAmuseMoreListAdapter(Activity context, List<PlayAmuseMoreList.Results> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        if (list != null && list.size() > 0) {
            return list.size();
        } else {
            return 0;
        }
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_amuse_more, null);

        foodlistoneheadimg = (ImageView) view.findViewById(R.id.amuse_list_item_head_img);
        GetVolleyHttp.getInstance(context).setImageLoader(foodlistoneheadimg,
                R.drawable.error_image, R.drawable.error_image, UrlConfig.URL + list.get(position).getPath());

        foodlistonetitletext = (TextView) view.findViewById(R.id.amuse_list_item_title_text);
        foodlistonetitletext.setText(list.get(position).getTitle());

        foodlistonepricetext = (TextView) view.findViewById(R.id.amuse_list_item_price_text);
        foodlistonepricetext.setText(list.get(position).getPrice());

        foodlistoneadresstext = (TextView) view.findViewById(R.id.amuse_list_item_adress_text);
        foodlistoneadresstext.setText(list.get(position).getAddress());

        foodlistonephonetext = (TextView) view.findViewById(R.id.amuse_list_item_phone_text);
        foodlistonephonetext.setText(list.get(position).getPhone());

        return view;
    }
}
